import { defineUserConfig } from 'vuepress'
import { docsBase } from './buildConfig'
import type { DefaultThemeOptions } from 'vuepress'

const { path } = require('@vuepress/utils')

/** 仓库地址 */
const repo = 'https://gitee.com/bhuh12/fdd-contract'

/** 开发环境 */
const isDev = process.env.NODE_ENV === 'development'

export default defineUserConfig<DefaultThemeOptions>({
  title: 'FddContract',
  description: '法大大合同控件',

  base: isDev ? '/' : docsBase,

  themeConfig: {
    repo,
    repoLabel: 'Git 仓库',

    navbar: [
      { text: '指南', link: '/guide/' },
      { text: '组件', link: '/component/viewer/contract.md' },
      { text: 'API 参考', link: '/api/config.md' },
      { text: '更新日志', link: '/guide/changelog.md' },
      { text: 'Demo', link: '/demo/', target: '_blank' },
      { text: 'NPM', link: 'http://npm.fabigbig.com/-/web/detail/fdd-contract' }
    ],

    sidebar: {
      '/guide/': [
        '/guide/README.md',
        '/guide/getting-started.md',
        {
          text: '场景示例',
          children: [
            '/guide/example/contract-view.md',
            '/guide/example/widget-status.md',
            '/guide/example/widget-set.md',
            '/guide/example/contract-fill.md',
            '/guide/example/contract-sign.md'
          ]
        },
        {
          text: '开发说明',
          children: [
            '/guide/develop/project.md',
            '/guide/develop/model.md',
            '/guide/develop/icon.md',
            '/guide/develop/release.md'
          ]
        },

        '/guide/changelog.md'
      ],
      '/component/': [
        {
          text: 'UI 组件',
          children: [
            '/component/ui/layout.md',
            '/component/ui/panel.md',
            '/component/ui/drag-resize.md',
            '/component/ui/drag-sort.md',
            '/component/ui/image-cropper.md',
            '/component/ui/tag.md'
          ]
        },
        {
          text: '文档查看',
          children: ['/component/viewer/contract.md', '/component/viewer/thumbs.md']
        },
        {
          text: '控件',
          children: [
            '/component/widget/widget-base.md',
            '/component/widget/widgets.md',
            '/component/widget/widget-setting.md',
            '/component/widget/widget-fill.md',
            '/component/widget/actors.md',
            '/component/widget/sign-select.md'
          ]
        }
      ],
      '/api/': ['/api/config.md', '/api/type.md', '/api/widget.md', '/api/utils.md']
    }
  },

  plugins: [
    [
      '@vuepress/register-components',
      {
        componentsDir: path.resolve(__dirname, './components')
      }
    ],

    [
      '@vuepress/plugin-search',
      {
        locales: {
          '/': {
            placeholder: '搜索'
          }
        }
      }
    ]
  ]
})
